 /*
 * @description: 班级认证列表
 * @Author: along
 * @Date: 2021-06-05
 * @Last Modified by: along
 * @Last Modified time: 2021-06-05
 */
<template>
    <div class="socialClassAuth">
        <div class="content-wrapper">

            <!-- header -->
            <div class="header">
                <div class="header-title">
                    班级认证列表
                </div>
            </div>
            <!-- 筛选-->
            <div class="filter-view">
                <div class="header-new-box">
                    <p class="header-new-box-title">学校名称</p>
                    <el-cascader
                        v-model="filterData.school_name"
                        placeholder="请选择学校"
                        :options="school_tree"
                        filterable
                        clearable
                        :show-all-levels="false"
                        size="medium"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                        :props="{
                            label: 'name',
                            value: 'name',
                            children: 'children',
                            emitPath: false
                        }"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">用户</p>
                    <el-input
                        v-model="filterData.keyword"
                        placeholder="请输入用户昵称/ID/手机号"
                        size="medium"
                        clearable
                        suffix-icon="el-icon-search"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">班级名称</p>
                    <el-input
                        v-model="filterData.class_name"
                        placeholder="请输入班级名称"
                        size="medium"
                        clearable
                        suffix-icon="el-icon-search"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">邀请码</p>
                    <el-input
                        v-model="filterData.invite_code"
                        placeholder="请输入邀请码"
                        size="medium"
                        clearable
                        suffix-icon="el-icon-search"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">精英等级</p>
                    <el-select
                        v-model="filterData.agent_level"
                        filterable
                        placeholder="全部"
                        size="medium"
                        style="width: 152px"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in levellist"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">班级认证时间</p>
                    <el-date-picker
                        v-model="date"
                        type="datetimerange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :default-time="['00:00:00', '23:59:59']"
                        align="right"
                        size="small"
                        @change="getTableData(1)"

                    />
                </div>
                <div class="header-new-box">
                    <div
                        class="header-button"
                        @click="getTableData(1)"
                    >
                        查询
                    </div>
                </div>
                <div class="header-new-box">
                    <div
                        class="header-rest"
                        @click="handleRestTabel()"
                    >
                        重置
                    </div>
                </div>
            </div>
            <!--筛选-->

            <!-- table -->
            <el-table
                :data="tableData"
                height="100%"
                style="width: calc(100% - 64px);marginLeft: 32px"
                ref="tempLateName"
                class="data-table"
                v-loading="loading"
            >
                <el-table-column
                    type="index"
                    label="序号"
                    width="80"
                    align="center"
                />
                <el-table-column
                    prop=""
                    label="用户信息"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                    :width="190"
                >
                    <template slot-scope="scope">
                        <div class="__zsdx_wrap">
                            <div class="__top">
                                <p class="__top_name">
                                    {{ scope.row.true_name }}
                                </p>
                                <img
                                    v-if="scope.row.is_stuagent"
                                    class="__top_logo"
                                    src="http://cdn.zsdx.cn/student-app/images/stuagent.png"
                                >
                            </div>
                            <div class="__phone">手机号：{{ scope.row.phone }}</div>
                            <div class="__id">用户ID：{{ scope.row.student_no }}</div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="agent_level"
                    label="精英等级"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="center"
                >
                    <template slot-scope="scope">
                        {{ scope.row.agent_level | filterLevel }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="invite_code"
                    label="邀请码"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                />
                <el-table-column
                    prop="school_name"
                    label="学校名称"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                />
                <el-table-column
                    prop="education_name"
                    label="学历"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                />
                <el-table-column
                    prop="class_name"
                    label="班级名称"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                >
                    <template slot-scope="scope">
                        <p
                            class="cursor_font"
                            @click="handleGoDetail(scope.row)"
                        >
                            {{ scope.row.class_name }}
                        </p>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="join_class_time"
                    label="班级认证时间"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                    align="left"
                >
                    <template slot-scope="scope">
                        {{ scope.row.join_class_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm:ss') }}
                    </template>
                </el-table-column>
            </el-table>
            <!-- /table -->

            <!-- /分页 -->
            <div class="pagination-wrapper clearfixNew">
                <el-pagination
                    layout="total, prev, pager, next, jumper"
                    background
                    :current-page.sync="page.now_page"
                    :total="page.total_count"
                    :page-size="page.page_size"
                    @current-change="getTableData"
                />
            </div>
        </div>
    </div>
</template>

<script>
import {back} from '@/mixin/back';
export default {
    mixins: [back],
    components: {
    },
    data() {
        return {
            loading: false,
            SELF: this,
            filterData: {
                keyword: '',
                school_name: '',
                class_name: '',
                invite_code: '',
                agent_level: 99
            },
            school_tree: [],
            date: [],
            levellist: [{value: 99, label: '全部'},{value: -1, label: '普通学生'},{value: 0, label: 'E0'},{value: 1, label: 'E1'},{value: 2, label: 'E2'},{value: 3, label: 'E3'},{value: 4, label: 'E4'},{value: 5, label: 'E5'}],
            tableData: [],
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 20
            },
            authResult: {}
        };
    },
    filters: {
        filterLevel (val) {
            if(val === -1) return '--';
            if(val === 0) return 'E0';
            if(val === 1) return 'E1';
            if(val === 2) return 'E2';
            if(val === 3) return 'E3';
            if(val === 4) return 'E4';
            if(val === 5) return 'E5';
            if(val === 6) return 'E6';
            return '--';
        }
    },
    mounted() {
        this.$store.commit('SET_HEADER', [{title: "APP后台"}, {title: '社交'}, {title: '班级管理'}, {title: '班级认证列表'}]);
        this.authResult = this.$route.meta.authResult;
        this.filterData.keyword = this.$route.query.student_no;
        this.getTableData();
        this.getSchoolTree();
    },
    methods: {
        /**
         * @description 获取表格数据
         */
        getTableData(page) {
            this.loading = true;
            this.$post('/student/region_class%5Cget_student_class_list', {
                page_id: page || this.page.now_page,
                ...this.filterData,
                start_time: this.date === null ? '' : (this.date.length === 0 ? '' : parseInt(new Date(this.date[0]).getTime() / 1000)),
                end_time: this.date === null ? '' : (this.date.length === 0 ? '' : parseInt(new Date(this.date[1]).getTime() / 1000))
            }, resp => {
                if (resp.code === 1) {
                    this.tableData = resp.data.list;
                    this.page = {
                        ...resp.data.page
                    };

                    this.loading = false;
                } else {
                    this.$notify({
                        title: '失败',
                        message: resp.msg,
                        duration: 2000,
                        type: 'warning'
                    });
                }
            });
        },

        /**
         * @description 获取省/市/学校三级联动
         */
        getSchoolTree() {
            this.$post('/student/local_info%5Cschool_tree', {}, resp => {
                if (resp.code === 1) {
                    this.school_tree = resp.data.tree;
                }
            });
        },

        /**
         * @description 班级详情
         */
        handleGoDetail (row) {
            this.$router.push({
                name: 'socialClassDetail',
                query: {
                    class_no: row.class_no,
                    from_type: 'socialClassAuth'
                }
            });
        },

        /**
         * @description 重置
         */
        handleRestTabel () {
            this.filterData = {
                keyword: '',
                school_name: '',
                class_name: '',
                invite_code: '',
                agent_level: 99
            };
            this.date = [];
            this.getTableData();
        },

        /**
         * @description 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        }
    }
};
</script>

<style scoped lang="less">
.socialClassAuth {
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    .content-wrapper {
        display: flex;
        height: calc(100% - 24px);
        flex-direction: column;
        position: relative;
        margin: 12px;
        background: #fff;
        box-sizing: border-box;
    }

    .__zsdx_wrap {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        .__top {
            display: flex;
            align-items: center;
            .__top_name {
                color: rgba(51, 51, 51, 1);
                font-size: 14px;
                font-weight: 500;
                margin-right: 6px;
            }
            .__top_logo {
                width: 28px;
                height: 14px;
            }
        }
        .__phone {
            height: 20px;
            color: rgba(153, 153, 153, 1);
            font-size: 14px;
            line-height: 20px;
            margin-top: 7px;
            margin-bottom: 5px;
        }
        .__id {
            height: 20px;
            color: rgba(153, 153, 153, 1);
            font-size: 14px;
            line-height: 20px;
        }
    }

    /*header*/

    .header {
        height: 68px;
        padding: 24px;
        box-sizing: border-box;
        box-shadow: 0px -1px 0px 0px #F0F2F5;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #F0F2F5;

        .header-title {
            color: #333333;
            font-size: 20px;
            height: 20px;
            font-weight: 500;
            position: relative;
            margin: 24px 0 24px 12px;

            &::before {
                content: '';
                position: absolute;
                left: -8px;
                top: -1px;
                width: 3px;
                height: 20px;
                background: #1890FF;
            }
        }
    }
    .btn-view {
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 24px 24px 0;
    }

    .cursor_font {
        color: rgba(24, 144, 255, 1);
        cursor: pointer;
    }

    /*筛选*/

    .filter-view {
        margin: 24px 0;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        margin-bottom: 0px;
        .header-new-box {
            display: flex;
            align-items: center;
            color: #606266;
            white-space: nowrap;
            margin-left: 32px;
            margin-bottom: 24px;
            &-title {
                margin-right: 12px;
                white-space: nowrap;
            }
            .header-button {
                width: 84px;
                height: 36px;
                border: 1px rgba(24, 144, 255, 1) solid;
                border-radius: 4px;
                text-align: center;
                line-height: 36px;
                color: rgba(24, 144, 255, 1);
                font-size: 14px;
                font-weight: 500;
                cursor: pointer;
            }
            .header-rest {
                color: rgba(24, 144, 255, 1);
                font-size: 14px;
                cursor: pointer;
                font-weight: 500;
                &:hover {
                    text-decoration: underline;
                }
            }
        }
    }

    .status-wrapper {
        display: flex;
        align-items: center;

        .status-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            margin-right: 5px;

            &.success {
                background: #4CD964;
            }

            &.danger {
                background: #FF3030;
            }

            &.warning {
                background: #FFA72D;
            }

            &.normal {
                background: #C2C2C2;
            }
        }
    }

    /* 分页 */

    .pagination-wrapper {
        padding: 10px 32px;

        .el-pagination {
            float: right;
            padding: 0;
            background-color: transparent;
        }
    }

    .text-button {
        width: 180px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        text-align: left;
    }
    // 表格
    .data-table {
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        // 操作按钮
        .option-btn-group {
            .el-button {
                margin-left: 0;
                margin-right: 10px;
            }
        }
    }

    /deep/ .el-dialog__header {
        padding-top: 10px;
        box-shadow:0 1px 0 0 rgba(233,233,233,1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;
        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }
        .el-icon-close:before {
            color: rgb(194,194,194);
            font-size: 17px;
            font-weight: bold;
        }
        .el-dialog__headerbtn {
            top: 14px;
        }
    }
    .dialog-footer {
        display: flex;
        justify-content: center;
    }
    /deep/ .el-table__fixed-right {
        right: 6px!important;
    }

    .el-popover-hover {
      border: none;
      background: transparent !important;
      border: none;
      outline: none;
      margin-left: -20px;
  }
}
</style>

<style lang="less">
.socialClassAuth {
    .el-icon-question {
        color: rgba(0, 0, 0, 0.3);
        margin-left: 2px;
    }
    .el-table .caret-wrapper {
        top: -1px;
    }
    .__title {
        color: rgba(51, 51, 51, 1);
        font-weight: 500;
    }
    .has-gutter {
        th .cell {
            color: rgba(51, 51, 51, 1);
            font-weight: 500;
        }
    }
    .el-dialog__header {
        padding-top: 10px;
        box-shadow:0px 1px 0px 0px rgba(233,233,233,1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;
        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }
        .el-icon-close:before {
            color: rgb(194,194,194);
            font-size: 17px;
            font-weight: bold;
        }
        .el-dialog__headerbtn {
            top: 14px;
        }
    }
    .el-dialog__body {
        padding-left: 32px;
        padding-right: 32px;
    }
    .__model {
        .el-table__body-wrapper {
            height: auto !important;
        }
    }
}

.clearfixNew {
    .btn-prev, .btn-next {
        background-color: transparent !important;
    }
    .el-pager .active {
        background-color: transparent !important;
        color: #20A0FF !important;
    }
    .el-pager .number {
        background-color: transparent !important;
        color: #606266;
    }
    .el-pagination__jump {
        margin-left: 20px;
    }
}
.zd-popper-class {
    text-align: left !important;
}
</style>
